// Fill out your copyright notice in the Description page of Project Settings.


#include "Characters/MyAnimInstance.h"
#include "Characters\MyCharacter.h"
#include "GameFramework\CharacterMovementComponent.h"
#include "Kismet\KismetMathLibrary.h"

void UMyAnimInstance::NativeInitializeAnimation()
{
	Super::NativeInitializeAnimation();
	MyCharacter = Cast<AMyCharacter>(TryGetPawnOwner());
	if (MyCharacter)
	{
		MyCharacetrMovement = MyCharacter->GetCharacterMovement();
	}
}

void UMyAnimInstance::NativeUpdateAnimation(float DeltaTime)
{
	Super::NativeUpdateAnimation(DeltaTime);

	if (MyCharacetrMovement)
	{
		GroundSpeed = UKismetMathLibrary::VSizeXY(MyCharacetrMovement->Velocity);
		IsFalling = MyCharacetrMovement->IsFalling();
		CharacterState = MyCharacter->GetCharacterState();
		ActionState = MyCharacter->GetActionState();
		DeathPoss = MyCharacter->GetDeathPoss();
	}
}
